﻿#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool Find(int target, vector<vector<int> >& array)
    {
        int i = 0;
        int j = array[0].size() - 1;
        while (i < array.size() && j >= 0)
        {
            if (array[i][j] < target)
            {
                i += 1;
            }
            else if (array[i][j] > target)
            {
                j -= 1;
            }
            else
            {
                return true;
            }
        }
        return false;
    }
};

